public class Student {
    private static final int LAB_CONTAINER_SIZE_INCREMENT = 5;
    private static final double EXCELLENT_RATE = 500;
    private static final double QUALIFIED_RATE = 300;
    private static final double UNQUALIFIED_RATE = 0;

    private int id;
    private String name;

    private double salary;

    private Lab[] studentLabs;
    private int currentNumberOfLabs;

    public static class TaxCalculator {
        private static final double TAX_BASE_LINE_LOW = 5000;
        private static final double NONE_TAXABLE_AMOUNT_LOW = 210;
        private static final double TAX_RATE_LOW = 0.03;

        private static final double TAX_BASE_LINE_HIGH = 8000;
        private static final double NONE_TAXABLE_AMOUNT_HIGH = 500;
        private static final double TAX_RATE_HIGH = 0.1;
        //计算税
        public static double calculateTax(double salary) {
            if (salary > TAX_BASE_LINE_HIGH) {
                return (salary * TAX_RATE_HIGH- NONE_TAXABLE_AMOUNT_HIGH) ;
            }
            else if (salary > TAX_BASE_LINE_LOW) {
                return (salary * TAX_RATE_LOW- NONE_TAXABLE_AMOUNT_LOW) ;
            } else {
                return 0;
            }
        }
    }

    public Student() { }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getGrossSalary() {
        return salary;
    }

    public double getNetSalary() {
        return this.salary - TaxCalculator.calculateTax(this.salary);
    }

    public Lab[] getStudentLabs() {
        return studentLabs;
    }

    public void setStudentLabs(Lab[] studentLabs) {
        this.studentLabs = studentLabs;
    }

    public Student(int ID, String Name) {
        this.id = ID;
        this.name = Name;
        this.salary = 0;
        this.studentLabs = new Lab[LAB_CONTAINER_SIZE_INCREMENT];
        this.currentNumberOfLabs = 0;
    }

    //为学生分配实验室
    public void addLab(Lab lab) {
        this.studentLabs[this.currentNumberOfLabs] = lab;
        this.currentNumberOfLabs ++;
        if (this.currentNumberOfLabs == this.studentLabs.length) {
            Lab[] studentLabs = new Lab[this.currentNumberOfLabs + LAB_CONTAINER_SIZE_INCREMENT];//扩容
            System.arraycopy(this.studentLabs, 0, studentLabs, 0, this.currentNumberOfLabs);//复制传值
            this.studentLabs = studentLabs;
        }
    }

    //卫生标准评定
    public  void evaluate(String[] standard) {
        try {
            for (String s : standard) {
                if (s.equals("优秀")) {
                    salary += EXCELLENT_RATE;
                } else if (s.equals("及格")) {
                    salary += QUALIFIED_RATE;
                } else if (s.equals("不及格")) {
                    salary += UNQUALIFIED_RATE;
                } else {
                    throw new Exception("等级输入异常! ");
                }
            }
        } catch (Exception exception) {
            System.out.println(exception);
        }
    }
}

